<?php
/**
 * 
 * list the projects
 * 
 * This php creates and lists all of the projects in the users area
 * The project titles are constructed from the directory names
 *
 * 
 * @copyright 2007 Loughborough University
 * @license http://www.gnu.org/licenses/gpl.txt
 * @version 0.0.0.1
 * @since 13 Oct 2009
 * 
 */
 
 
 //start directory to the users projects
 $path = dirname( __FILE__ );
 $fullPath = $path . '/../users/test' . '/';				//../users/test will be replaced by the username of the person using the tool!
 
 //scan the directory
 $projectsList = scandir($fullPath);
 
 //sort through the returned array and remove the . and .. directory attributes
 $key = array_search(".", $projectsList);
 unset($projectsList[$key]);
 $key = array_search("..", $projectsList);
 unset($projectsList[$key]);
 
 //loop through the remaining array and write out the projects to xml to be picked up by the flex app.
 $doc = new DOMDocument('1.0', 'iso-8859-1');
 $root = $doc->createElement('projects');
 $doc->appendChild($root);
 
 foreach($projectsList as $project){
 	 $block = $doc->createElement('project');
 	 
 	 $block->appendChild($doc->createTextNode($project));
 	 $root->appendChild($block);
 }
 	
 $xml_string = $doc->saveXML();
 echo $xml_string;
 
?>